package com.email.bussiness;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.LinkedList;
import java.util.List;

import com.email.base.DBConnection;
import com.email.bean.Operator;
import com.jgeppert.struts2.jquery.tree.result.TreeNode;
/**
 * 操作员表操作类<p/>
 * @author victor
 *
 */
public class OperatorDao implements IOperatorDao{
	
	/**
	 * 根据账户、密码查询操作员信息。
	 */
	public Operator findOperator(String username, String password) {
		String sqlFind = "SELECT USERNAME, PASSWORD, PRIVILEDGE FROM OPERATOR WHERE USERNAME = '"+username+"' and PASSWORD = '"+password+"'";
		Operator operator = null;
		Connection conn = DBConnection.getConnection();
		try {
			Statement stmt = conn.createStatement();
			ResultSet rs = stmt.executeQuery(sqlFind);

			while(rs.next()){
				operator = new Operator();
				operator.setUsername(rs.getString("USERNAME"));
				operator.setPassword(rs.getString("PASSWORD"));
				operator.setPriviledge(rs.getString("PRIVILEDGE"));				
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (NullPointerException enull){
			enull.printStackTrace();
		}
		return operator;
	}

	/**
	 * 获取相应USER自定义的文件夹信息。
	 * @param username
	 * @return
	 */
	public TreeNode getNode(String username){
		TreeNode nodes = new TreeNode();
		return nodes;
	}
	
	@Override
	public List<Operator> findAllOperators() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void createOperator(Operator operator) {
		// TODO Auto-generated method stub
		
	}
}
